package com.mybatisflex.demo.listener;

import com.mybatisflex.annotation.AbstractInsertListener;
import com.mybatisflex.demo.entity.Card;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * @author 王帅
 * @since 2023-07-18
 */
@Slf4j
public class CardInsertListener extends AbstractInsertListener<Card> {

    @Override
    public Class<Card> supportType() {
        return Card.class;
    }

    @Override
    public void doInsert(Card card) {
        log.info("执行 CardInsertListener 中的 doInsert 方法");
        card.setIdNumber(UUID.randomUUID().toString());
        card.setCreateTime(LocalDateTime.now());
    }

    @Override
    public int order() {
        return 1;
    }

}